usALEX - Corrections - Direct excitation physical parameter

This compares different bursts searches.

Library imports


In [1]:
from __future__ import division
import os
import numpy as np
import pandas as pd
#import lmfit

In [7]:
%matplotlib inline
import matplotlib.pyplot as plt

Load data RAW PR data


In [17]:
d = {}

for bsearch_ph_sel in ['all-ph', 'Dex', 'AND-gate']:
    data_file = 'results/usALEX-5samples-PR-raw-%s.txt' % bsearch_ph_sel
    d[bsearch_ph_sel] = pd.read_csv(data_file, sep="\s+").set_index('sample')[['E_pr_fret_kde']]
    #d[bsearch_ph_sel].columns = [bsearch_ph_sel]

In [12]:
fig, ax = plt.subplots()

for bs, data in d.items():
    data.plot(label=bs, ax=ax)



In [21]:
(d['AND-gate'] - d['all-ph']).abs().max()*100


Out[21]:
E_pr_fret_kde    0.8
dtype: float64

In [25]:
(d['AND-gate'] - d['Dex']).abs()


Out[25]:
E_pr_fret_kde
sample
7d 0.0020
12d 0.0016
17d 0.0002
22d 0.0006
27d 0.0000

In [23]:
(d['all-ph'] - d['Dex']).abs().max()*100


Out[23]:
E_pr_fret_kde    0.96
dtype: float64

In [26]:
d['Dex']


Out[26]:
E_pr_fret_kde
sample
7d 0.9336
12d 0.7510
17d 0.4908
22d 0.2752
27d 0.1944

In [2]:
#bsearch_ph_sel = 'all=ph'
#bsearch_ph_sel = 'AND-gate'
bsearch_ph_sel = 'Dex'

data_file = 'results/usALEX-5samples-PR-raw-%s.txt' % bsearch_ph_sel

These are the RAW proximity ratios for the 5 samples (only background correction, no leakage nor direct excitation):


In [3]:
data_raw = pd.read_csv(data_file, sep="\s+").set_index('sample')
data_raw[['E_pr_fret', 'E_pr_fret_kde']]


Out[3]:
E_pr_fret E_pr_fret_kde
sample
7d 0.927586 0.9336
12d 0.749365 0.7510
17d 0.480290 0.4908
22d 0.280477 0.2752
27d 0.194521 0.1944

Load μs-ALEX corrections


In [4]:
leakage_coeff_fname = 'results/usALEX - leakage coefficient DexDem.txt'
leakage = np.loadtxt(leakage_coeff_fname)

print 'Leakage coefficient:', leakage


Leakage coefficient: 0.0999978359136

In [5]:
dir_ex_t_datasheet_fname = 'results/Dyes - ATT0647N-ATTO550 abs X-section ratio at 532nm.txt'
dir_ex_t_datasheet = np.loadtxt(dir_ex_t_datasheet_fname)

print 'Direct excitation (dir_ex_t) from datasheet:', dir_ex_t_datasheet


Direct excitation (dir_ex_t) from datasheet: 0.106516290727

In [6]:
gamma_coeff_fname = 'results/usALEX - gamma factor - all-ph.txt'
gamma = np.loadtxt(gamma_coeff_fname)

print 'Gamma factor:', gamma


Gamma factor: 1.02500832027

Load E data from corrected FRET bursts

And these are the FRET efficiencies fitted from corrected histograms for the same 5 samples:


In [7]:
data_file = 'results/usALEX-5samples-E-corrected-all-ph.txt'
data_corr = pd.read_csv(data_file, sep="\s+").set_index('sample')
data_corr[['E_pr_fret', 'E_pr_fret_kde']]


Out[7]:
E_pr_fret E_pr_fret_kde
sample
7d 0.926023 0.9300
12d 0.730013 0.7416
17d 0.430222 0.4370
22d 0.191358 0.1874
27d 0.093747 0.0972

Proximity Ratio correction formula

The expression to convert RAW PR values to corrected FRET efficiencies:

$$ E = \frac{E_{R} \left(L_{k} + d_{exT} \gamma + 1\right) - L_{k} - d_{exT} \gamma}{E_{R} \left(L_{k} - \gamma + 1\right) - L_{k} + \gamma}$$

See Derivation of FRET and S correction formulas for the derivation.

We load FRETBursts software that provides this function (as fretmath.correct_E_gamma_leak_dir):


In [8]:
%run load_fretbursts.py --nogui


 - Optimized (cython) burst search loaded.
 - Optimized (cython) photon counting loaded.

FRETBursts revision:
 2014-08-16 68e0ade Better KDE normalization in hist_fret_kde() plot

Comparison of datasheet-based vs μs-ALEX-based direct excitation

Using datasheet values for $d_{exT}$ we the following FRET efficiencies:


In [9]:
E_datasheet = fretmath.correct_E_gamma_leak_dir(data_raw.E_pr_fret_kde, 
                                                leakage=leakage, 
                                                dir_ex_t=dir_ex_t_datasheet,
                                                gamma=gamma)*100
E_datasheet


Out[9]:
array([ 92.43130215,  71.22134243,  39.95430179,  13.06912254,   2.75506448])

In [10]:
out = data_corr[['E_pr_fret_kde']].copy()*100
out.columns = ['E_alex']
out['E_datasheet'] = E_datasheet
out


Out[10]:
E_alex E_datasheet
sample
7d 93.00 92.431302
12d 74.16 71.221342
17d 43.70 39.954302
22d 18.74 13.069123
27d 9.72 2.755064

In [11]:
out.plot(alpha=0.4, lw=3, style=dict(E_alex='-ob', E_datasheet='-sr'));


NOTE: The corrected FRET efficiencies using the datasheet and μs-ALEX-based direct excitation do not match well.

Fitting of physical direct excitation coefficient $d_{exT}$


In [12]:
import lmfit

In [13]:
def residuals_absolute(params, E_raw, E_ref):
    dir_ex_t = params['dir_ex_t'].value
    return E_ref - fretmath.correct_E_gamma_leak_dir(E_raw, 
                                                     leakage=leakage, 
                                                     gamma=gamma, 
                                                     dir_ex_t=dir_ex_t)

In [14]:
def residuals_relative(params, E_raw, E_ref):
    dir_ex_t = params['dir_ex_t'].value
    return (E_ref - fretmath.correct_E_gamma_leak_dir(E_raw, 
                                                      leakage=leakage, 
                                                      gamma=gamma, 
                                                      dir_ex_t=dir_ex_t))/E_ref

In [15]:
params = lmfit.Parameters()
params.add('dir_ex_t', value=0.05)

In [16]:
m = lmfit.minimize(residuals_absolute, params, args=(data_raw.E_pr_fret_kde, data_corr.E_pr_fret_kde))
lmfit.report_fit(m.params, show_correl=False)


[[Variables]]
     dir_ex_t:     0.0301536 +/- 0.004201888 (13.93%) initial =  0.05

In [17]:
m = lmfit.minimize(residuals_relative, params, args=(data_raw.E_pr_fret_kde, data_corr.E_pr_fret_kde))
lmfit.report_fit(m.params, show_correl=False)


[[Variables]]
     dir_ex_t:     0.02860964 +/- 0.001570824 (5.49%) initial =  0.0301536

NOTE: The fitted dir_ex_t is XX% as opposed to 10.6% as expected from the absorption spectra of ATTO550 and ATTO647 at 532nm.


In [21]:
m.params['dir_ex_t'].value


Out[21]:
0.028609637544006607

In [20]:
with open('results/usALEX - leakage coefficient dir_ex_t.txt', 'w') as f:
    f.write(str(m.params['dir_ex_t'].value))

In [20]: